package com.itheima.chapter11;

import java.net.InetAddress;
import java.net.UnknownHostException;

/*
InetAddress 表示Internet协议(IP)地址
 */
public class InetAddressDemo {
    public static void main(String[] args) throws UnknownHostException {
        InetAddress address =InetAddress.getByName("192.168.0.101");
        InetAddress address1 =InetAddress.getByName("DESKTOP-DI9RER3");
        String hostAddress = address.getHostAddress();
        String hostName = address.getHostName();
        System.out.println(hostAddress);
        System.out.println(hostName);
        System.out.println("---------------------");
        System.out.println(address1.getHostName());
        System.out.println(address1.getHostAddress());
    }
}
